import { Button } from 'antd';
import { useEffect } from 'react';
import { useChooseDir } from 'renderer/hook/useChoose';
import './index.css';
function ExportLog() {
  const [exportDir, startChooseExportDir] = useChooseDir('');
  const doExportLog = () => {
    if (exportDir === '') {
      window.electronAPI.ipcRenderer.showError('错误', '需要导出路径');
      return;
    }
    window.electronAPI.ipcRenderer.exportLog(exportDir);
    window.electronAPI.ipcRenderer.showMessage('成功', '导出成功');
  };
  return (
    <div id="export-log-container">
      <h1>导出软件日志</h1>
      <div>
        <Button type="primary" onClick={startChooseExportDir}>
          1.选择文件夹
        </Button>
      </div>
      <p>导出文件夹：{exportDir}</p>
      <div>
        <Button type="primary" onClick={doExportLog}>
          2.导出
        </Button>
      </div>
    </div>
  );
}
export default ExportLog;
